package com.ymatou.iapi.dguser.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.CreateUserBackBean;
import com.ymatou.iapi.dguser.parameter.GetUserIdsByMobileBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.GetUserIdsByMobileCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.utils.TestDataManager;
/**
*手机号查询用户列表分页Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetUserIdsByMobile{
	private static GetUserIdsByMobileBean getuseridsbymobileBean;
	private static GetUserIdsByMobileCall getuseridsbymobileCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("手机号查询用户列表分页Test");
	}

	@Before
	public void caseUp() {
		getuseridsbymobileBean=new GetUserIdsByMobileBean();
		getuseridsbymobileCall=new GetUserIdsByMobileCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getuseridsbymobileCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserIdsByMobile_001() {
		Logger.start(true,"正确数据，成功");
		try {
			
			CreateUserBackBean usercreateBean = DGUserCallService.initUsercreateNewBean();
			usercreateBean.setMobile(TestDataManager.getPhoneNum());
			int userId=DGUserCallService.UserCreateNewCall(usercreateBean);
			DGUserCallService.ReceiveUserCreateNewCall(userId);
			getuseridsbymobileBean.setMobile(usercreateBean.getMobile());
			getuseridsbymobileBean.setWxAppName(userId+"");
			getuseridsbymobileBean.setPageSize(20);
			getuseridsbymobileBean.setPageNum(1);
			getuseridsbymobileCall.setData(getuseridsbymobileBean);
			getuseridsbymobileCall.callService();			
			Logger.verifyEquals("true", getuseridsbymobileCall.getString("success"), "验证code");
			Logger.verifyEquals("1", getuseridsbymobileCall.getString("totalCount"), "验证获取总条数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserIdsByMobile_002() {
		Logger.start(true,"手机号错误，查询失败");
		try {
			CreateUserBackBean usercreateBean = DGUserCallService.initUsercreateNewBean();
			usercreateBean.setMobile(TestDataManager.getPhoneNum());
			int userId=DGUserCallService.UserCreateNewCall(usercreateBean);
			DGUserCallService.ReceiveUserCreateNewCall(userId);
			getuseridsbymobileBean.setMobile(usercreateBean.getMobile()+"123");
			getuseridsbymobileBean.setWxAppName(userId+"");
			getuseridsbymobileBean.setPageSize(20);
			getuseridsbymobileBean.setPageNum(1);
			getuseridsbymobileCall.setData(getuseridsbymobileBean);
			getuseridsbymobileCall.callService();			
			Logger.verifyEquals("true", getuseridsbymobileCall.getString("success"), "验证code");
			Logger.verifyEquals("0", getuseridsbymobileCall.getString("totalCount"), "验证获取总条数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserIdsByMobile_003() {
		Logger.start(true,"微信小程序名称与手机号不匹配，查询失败");
		try {
			CreateUserBackBean usercreateBean = DGUserCallService.initUsercreateNewBean();
			usercreateBean.setMobile(TestDataManager.getPhoneNum());
			int userId=DGUserCallService.UserCreateNewCall(usercreateBean);
			getuseridsbymobileBean.setMobile(usercreateBean.getMobile());
			getuseridsbymobileBean.setWxAppName("testseller");
			getuseridsbymobileBean.setPageSize(20);
			getuseridsbymobileBean.setPageNum(1);
			getuseridsbymobileCall.setData(getuseridsbymobileBean);
			getuseridsbymobileCall.callService();			
			Logger.verifyEquals("true", getuseridsbymobileCall.getString("success"), "验证code");
			Logger.verifyEquals("0", getuseridsbymobileCall.getString("totalCount"), "验证获取总条数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserIdsByMobile_004() {
		Logger.start(true,"小程序名称为空");
		try {
			CreateUserBackBean usercreateBean = DGUserCallService.initUsercreateNewBean();
			usercreateBean.setMobile(TestDataManager.getPhoneNum());
			int userId=DGUserCallService.UserCreateNewCall(usercreateBean);
			getuseridsbymobileBean.setMobile(usercreateBean.getMobile());
			getuseridsbymobileBean.setWxAppName("");
			getuseridsbymobileBean.setPageSize(20);
			getuseridsbymobileBean.setPageNum(1);
			getuseridsbymobileCall.setData(getuseridsbymobileBean);
			getuseridsbymobileCall.callService();			
			Logger.verifyEquals("false", getuseridsbymobileCall.getString("success"), "验证code");
			Logger.verifyEquals("0", getuseridsbymobileCall.getString("totalCount"), "验证获取总条数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserIdsByMobile_005() {
		Logger.start(true,"手机号为空");
		try {
			CreateUserBackBean usercreateBean = DGUserCallService.initUsercreateNewBean();
			usercreateBean.setMobile(TestDataManager.getPhoneNum());
			int userId=DGUserCallService.UserCreateNewCall(usercreateBean);
			getuseridsbymobileBean.setMobile(null);
			getuseridsbymobileBean.setWxAppName(userId+"");
			getuseridsbymobileBean.setPageSize(20);
			getuseridsbymobileBean.setPageNum(1);
			getuseridsbymobileCall.setData(getuseridsbymobileBean);
			getuseridsbymobileCall.callService();			
			Logger.verifyEquals("false", getuseridsbymobileCall.getString("success"), "验证code");
			Logger.verifyEquals("0", getuseridsbymobileCall.getString("totalCount"), "验证获取总条数");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}